import React, {PureComponent} from 'react';
import {connect} from 'dva';
import  DistributeCountReportGoodList from '../../components/Report/DisbuteCountReportGoodList/index'
import {routerRedux} from 'dva/router'
import {
    Row,
    Col,
    Card,
    Form,
    Input,
    Select,
    Button,
    DatePicker,
    Modal,
    message
} from 'antd';
import styles from './distributeGoodsList.less';
import PageHeaderLayout from '../../layouts/PageHeaderLayout';
const getValue = obj => Object.keys(obj).map(key => obj[key]).join(',');
@connect(state => ({
    rule: state.distributeCountReportGoodsList,
}))
export default class DistributeCountReport extends PureComponent{
    state = {
        formValues: {},
        record: {},
        selectedRows: [],
        recObjectVisible: false,

    };


    componentDidMount() {

        const shop_id = this.props.location.state.shop_id;
        const   add_time = this.props.location.state.add_time;
        const   nick_name= this.props.location.state.nick_name;
        const   order_status= this.props.location.state.order_status;
        const    pay_status= this.props.location.state.pay_status;
        const    shipping_status= this.props.location.state.shipping_status;
        const   timeType= this.props.location.state.timeType;
        const params = ({
            shop_id:shop_id,
            add_time:add_time,
            nick_name:nick_name,
            order_status:order_status,
            pay_status:pay_status,
            shipping_status:shipping_status,
            timeType:timeType,
        })
        const {dispatch} = this.props;
        dispatch({
            type: 'distributeCountReportGoodsList/fetch',
            payload:params
        });
        this.setState({
            formValues:params
        })
    }


    handleOrderListChange = (pagination) => {
        const {dispatch} = this.props;
        const {formValues} = this.state;

        const params = {
            currentPage: pagination.current,
            pageSize: pagination.pageSize,
            ...formValues,
        };

        dispatch({
            type: 'distributeCountReportGoodsList/fetch',
            payload: params,
        });
    }

    render() {
        const {selectedRows,recObjectVisible} = this.state;
        const {rule: {loading: ruleLoading, data }} = this.props;
        return (
            <PageHeaderLayout title="分销商销售商品清单">
                <Card bordered={false}>
                    <DistributeCountReportGoodList
                        selectedRows={selectedRows}
                        loading={ruleLoading}
                        data={data}
                        onSelectRow={this.handleSelectRows}
                        onChange={this.handleOrderListChange}
                        onDelRow={this.handleDelBrandRow}
                        onEditRow={this.handleEditBrandRow}
                        onRecommendRow={this.handleRecommendRow}
                    />

                </Card>
            </PageHeaderLayout>


        )


    }


}